/* Exercise 5.29
   ejer5_29.c */
#include <stdio.h>

int gcd( int number1, int number2 );

/* function main begins program execution */
int main( void )
{
    int a, b;

    printf( "Enter a number: " );
    scanf( "%d", &a );
    printf( "Enter another number: " );
    scanf( "%d", &b );

    printf( "The GCD is: %d\n", gcd( a, b ));
	return 0; /* indicate that program ended successfully */
} /* end function main */

int gcd( int number1, int number2 )
{
    int module;

    module = number1 % number2;

    while ( module != 0 )
    {
        number1 = number2;
        number2 = module;

        module = number1 % number2;
    }

    return number2;
}
